package com.atguigu.gmall.user.rpc;


import com.atguigu.gmall.common.config.interceptor.UserAuthContext;
import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.cart.entity.UserAuth;
import com.atguigu.gmall.model.user.entity.UserAddress;
import com.atguigu.gmall.user.service.UserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/inner/user")
public class UserRpcController {

    @Autowired
    UserAuthContext userAuthContext;

    @Autowired
    UserAddressService userAddressService;

    /**
     * 获取下单用户的地址列表
     * @return
     */
    @GetMapping("/getUserAddressList")
    public Result<List<UserAddress>> getUserAddressList() {
        UserAuth userAuth = userAuthContext.getUserAuth();
        List<UserAddress> list = userAddressService.lambdaQuery()
                .eq(UserAddress::getUserId, userAuth.getUserId())
                .list();
        return Result.ok(list);

    }
 }
